﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using WaterRegimenMonitor.Web.Domain;
using WaterRegimenMonitor.Web.Code;
using WaterRegimenMonitor.Common;

namespace WaterRegimenMonitor.Web.Controllers
{
    /// <summary>
    /// 最新水情查询控制器。
    /// </summary>
    public class NewlyReportController : Controller
    {
        /// <summary>
        /// 默认动作。
        /// </summary>
        /// <returns></returns>
        /// <remarks></remarks>
        //[RequireAuthorization]
        //[HandleError(Order = 3, ExceptionType = typeof(UnauthenticatedException), View = "Unauthenticated")]
        //[HandleError(Order = 2, ExceptionType = typeof(UnauthorizedException), View = "Unauthorized")]
        //[HandleError(Order = 1, ExceptionType = typeof(Exception), View = "Exception")]
        public ActionResult Index()
        {
            return View();
        }

        /// <summary>
        /// 查询测站水情列表
        /// </summary>
        /// <param name="query">查询条件模型。</param>
        /// <returns>查询的测站水情列表</returns>
        /// <remarks></remarks>
        [HttpGet]
        [JsonHandleError]
        public JsonResult Select(JosnPagingQueryModel query)
        {
            //查询数据
            var result = StationHelper.QueryNewlyWater(query);

            //返回结果
            return new JsonNetResult()
            {
                Data = new JsonResultViewModel { total = result.Total, data = result.Data, success = true },
                JsonRequestBehavior = JsonRequestBehavior.AllowGet,
                ContentEncoding = null,
                ContentType = null
            };
        }
    }
}
